<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/2/21
 * Time: 10:06
 */

namespace app\index\controller;


use think\Controller;
use think\Db;

class Newstype extends Controller
{
    /**
     *用于显示添加页面
     */
    public function add()
    {
        return view();
    }

    /**
     * 保存用户提交的数据
     */
    public function save()
    {
        //1.接收用户提交的类型名称
        $typename = $_REQUEST["typeName"];
        //2.将接收到的数据提交到数据库
        $data = ["typeName"=>$typename];
        Db::table("zy_newstype")->insert($data);
        //3.判断执行结果
    }

    public function update($id=null,$typeName=null)
    {
        $model = db("newstype");
        $r = $model->where("id",$id)->update(["typeName"=>$typeName]);
        echo $model->getLastSql();
        if($r){
            echo "10";
        }else{
            echo "00";
        }
    }

}